<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
	<?php
	include_once("../handlerxml/SMSXmlHandler.php");
	include_once("../controlador/GestorSMS.php");

	// Make sure the user is posting
	if ($_SERVER['REQUEST_METHOD'] === 'POST') {
	    // Read the input from stdin
	    $postText = trim(file_get_contents('php://input'));
	    echo $postText;
	    error_log($postText);


	    $g_listaSMS = array();
	    $g_elem = null;


	    $parser = xml_parser_create();

	    xml_set_element_handler($parser, "startElement", "endElement");
	    xml_set_character_data_handler($parser, "textData");

	    xml_parse($parser, $postText);

	    xml_parser_free($parser);


	    foreach ($g_listaSMS as $smsArray) {
		error_log('IDSMS: ' . $smsArray['IDSMS']);
		error_log('ESTADO: ' . $smsArray['ESTADO']);
	    }
	    
	    $gestorSMS = new GestorSMS();
	    $gestorSMS->updateSMSStated($g_listaSMS);
	}
	?>
    </body>
</html>
